#ifndef _COM_H_
#define _COM_H_

#include <stdbool.h>
#include <windows.h>

#define COM_NUM_MAX         (1024)
#define COM_NAME_MAX        (256 * 2)

#define COM_READ_BUFSIZE    (1024)
#define COM_WRITE_BUFSIZE   (1024)

typedef struct {
    bool available;
    HANDLE handle;
    char name[COM_NAME_MAX];
    char friendly_name[COM_NAME_MAX];
} com_t;

typedef struct {
    DWORD baudrate;
    BYTE databits;
    BYTE stopbits;
    BYTE parity;
} com_config_t;

int scan_com(void);
com_t *get_com(int index);

int open_com(com_t *com);
int config_com(com_t *com, com_config_t *config);


#endif
